package cn.b.sky.mes.mm.controller;

import java.util.List;

import javax.annotation.Resource;

import cn.b.sky.mes.mm.model.Warehouse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.b.sky.mes.mm.model.condition.DistributionKanBanCondition;
import cn.b.sky.mes.mm.service.DistributionService;
import cn.b.sky.mes.mm.service.WarehouseService;
import cn.b.sky.user.controller.SecurityController;

/**
 * 
 * <strong>Title : RequirementKanBanController.java<br></strong>
 * <strong>Package : cn.b.sky.mes.cm.controller<br></strong>
 * <strong>Description : </strong>需求看板控制器<br> 
 * <strong>Create on : 2016-9-22 上午11:42:56<br></strong>
 * <p>
 * @author lidapeng<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人|修改日期|修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
@Controller
@RequestMapping("/xqkanban/*")
public class DistributionKanBanController extends SecurityController {

  @Resource
  DistributionService distributionService;
  
  @Resource
  WarehouseService warehouseService;
  
  /**
   * 
   * <strong>Title : requirementKanBanList<br></strong>
   * <strong>Description : </strong>TODO@方法注释说明写在此处@<br> 
   * <strong>Create on : 2016-9-30 上午9:57:45<br></strong>
   * <p>
   * @param navTabId
   * @param timeInterval 定时器参数，保存用于下次清楚定时器
   * @param condition
   * @param model
   * @return
   * String
   * @throws 
   * @author lidapeng<br>
   * @version <strong>v1.0.0</strong><br>
   * <br>
   * <strong>修改历史:</strong><br>
   * 修改人 | 修改日期 | 修改描述<br>
   * -------------------------------------------<br>
   * <br>
   * <br>
   */
  @RequestMapping("list")
  public String requirementKanBanList(String navTabId, String timeInterval,
      @ModelAttribute("condition")DistributionKanBanCondition condition, Model model) {
    condition.setSiteCode(this.getSiteCode());
    condition.setData(distributionService.getRequirementsKanBanByCondition(condition));
    condition.setTotalCount(distributionService.getRequirementsKanBanCountByCondition(condition));
    List<Warehouse> warehouses = warehouseService.selectUnLockWarehouseListBySiteCode(getSiteCode());
    model.addAttribute("page", condition);
    model.addAttribute("navTabId", navTabId);
    model.addAttribute("timeInterval", timeInterval);
    model.addAttribute("warehouses", warehouses);
    return "mm/requirement/requirement_kenban";
  }
}
